var TextViewMap = new Object();
var TextView = function(opt){
	this.target = opt.target?opt.target:'textView';
	this.content = opt.content?opt.content:'pTextViewContent';
	this.height = opt.height?opt.height:150;
	
	this.addValue = opt.addValue?opt.addValue:3;
	this.interval = opt.interval?opt.interval:1;
	this.length = 0;
	this.top=0;
	this.timer = null;
	TextViewMap[this.target] = this;
}

TextView.prototype = {
	setContent:function(html,run){
		if(this.timer!=null){clearInterval(this.timer);this.timer = null;}
		var content = document.getElementById(this.content);
		this.top = this.addValue;
		content.style.top = this.top;
		content.innerHTML = html;
		this.length = content.offsetHeight; 
		if(run && this.length > this.height){
			this.timer = setInterval("textViewInterval('"+this.target+"')",this.interval);
		}
	},
	run:function(){
		if(this.timer) return ;
		if(this.length > this.height){
			this.timer = setInterval("textViewInterval('"+this.target+"')",this.interval);
		}
	},
	stop:function(){
		if(this.timer!=null){clearInterval(this.timer);this.timer = null;}
	},
	clear:function(){
		this.stop();
		var content = document.getElementById(this.content);
		content.innerHTML = '';
	},
}

function textViewInterval(tar){
	var _this = TextViewMap[tar];
	_this.top = _this.top - _this.addValue;	
	
	if(Math.abs(_this.top)> Math.abs(_this.length)){
		_this.top = _this.height;
	}
	
	var content = document.getElementById(_this.content);
	content.style.top = _this.top; 
}